package com.cwl.common.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能描述：
 *      常量类
 * @author cwledit
 * @date 2017/11/10
 */
public class UEConstants {

	public final static String ENCODING = "UTF-8";

	public static final String URL_PAY = "/pay/v6/";

	public static final String URL_NOTIFY_V5 = URL_PAY + "notify";

	public static final String URL_UEPAY = "/pay/v6uePay";

	public static final String URL_ABCUEPAY = "/pay/v6abcuePay";


	public static final String URL_OPENID = "/pay/auth/v6openid";

	public static final String PRODUCT_CODE_ALIQRCODE_NATIVE = "12";

	public static final String PRODUCT_CODE_WXQRCODE_NATIVE = "22";

	public static final String PRODUCT_CODE_UEQRCODE = "30";
	public static final String PRODUCT_CODE_UESCAN = "40";

	public static final String PRODUCT_CODE_CCBSCAN = "70";

	public static final String PRODUCT_CODE_CCBQRCODE_NATIVE = "50";

	public static final String PRODUCT_CODE_RECONCILIATION = "60";
	/** 二维码 支付宝扫码付款 */
	public final static String TRADE_WAY_ALI_QRCODE = "ALI_QRCODE";
	/** 二维码 支付宝付款码付款 */
	public final static String TRADE_WAY_ALI_SCAN = "ALI_SCAN";
	/** 二维码 微信扫码付款 */
	public final static String TRADE_WAY_WX_QRCODE = "WX_QRCODE";
	/** 二维码 微信付款码付款 */
	public final static String TRADE_WAY_WX_SCAN = "WX_SCAN";
	/** 二维码 建行扫码付款 */
	public final static String TRADE_WAY_CCB_QRCODE = "CCB_QRCODE";
	/** 二维码 聚合（支付宝与微信）扫码付款 */
	public final static String TRADE_WAY_UE_QRCODE = "UE_QRCODE";
	/** 二维码 聚合（支付宝与微信）扫码付款 农行 */
	public final static String TRADE_WAY_ABC_UE_QRCODE = "ABC_UE_QRCODE";
	/** 二维码 银联扫码付款 */
	public final static String TRADE_WAY_UNIONPAY_QRCODE = "UNIONPAY_QRCODE";
	/** 二维码 工行扫码 */
	public final static String TRADE_WAY_ICBC_QRCODE = "ICBC_QRCODE";
	/** 二维码 农行扫码 */
	public final static String TRADE_WAY_ABC_QRCODE = "ABC_QRCODE";
	/** 二维码 银联商务扫码 */
	public final static String TRADE_WAY_UMS_QRCODE = "UMS_QRCODE";
	/** 付款码 被扫支付（支持支付宝与微信付款码）*/
	public final static String TRADE_WAY_UE_SCAN = "UE_SCAN";
	/** 付款码 建行下单支付（支持支付宝、微信、龙支付）*/
	public final static String TRADE_WAY_CCB_SCAN = "CCB_SCAN";
	/** 付款码 银联付款码*/
	public final static String TRADE_WAY_UNIONPAY_SCAN = "UNIONPAY_SCAN";

	/** 付款码 工行*/
	public final static String TRADE_WAY_ICBC_SCAN = "ICBC_SCAN";

	/** 二维码 甬易 */
	public final static String TRADE_WAY_YONGYI_QRCODE = "YONGYI_QRCODE";


	/** 外部订单 上传 **/
	public final static String TRADE_WAY_BANK_POS = "BANK_POS";

	/** 对账 */
	public final static String TRADE_WAY_UE_RECONCILIATION = "UE_RECONCILIATION";

	/** 微信支付 */
	public static final String CHANNEL_TYPE_WX = "WX";
	/** 支付宝支付 */
	public static final String CHANNEL_TYPE_ALI = "ALI";
	/** 建行聚合支付 */
	public static final String CHANNEL_TYPE_CCB= "CCB";
	public static final String CHANNEL_TYPE_CCBPOS= "CCB_POS";
	/** 银联支付 */
	public static final String CHANNEL_TYPE_UNIONPAY = "UNIONPAY";
	/** 农行支付 */
	public static final String CHANNEL_TYPE_ABC = "ABC";
	public static final String CHANNEL_TYPE_ABCPOS = "ABC_POS";
	/** 农行支付 */
	public static final String CHANNEL_TYPE_ICBC = "ICBC";
	/** 银联商务支付 */
	public static final String CHANNEL_TYPE_UMS = "UMS";

	/** 银行POS交易 */
	public static final String CHANNEL_TYPE_BANKPOS = "BANKPOS";

	/** 甬易支付 */
	public static final String CHANNEL_TYPE_YONGYI = "YONGYI";

	public static final Object REFUND_SOURCE_BOSS = "BOSS";

	public static Map<String,String> CHANNEL_TYPE_LABLE = new HashMap<>();
	static {
		CHANNEL_TYPE_LABLE.put(CHANNEL_TYPE_WX,"微信");
		CHANNEL_TYPE_LABLE.put(CHANNEL_TYPE_ALI,"支付宝");
		CHANNEL_TYPE_LABLE.put(CHANNEL_TYPE_CCB,"龙支付");
		CHANNEL_TYPE_LABLE.put(CHANNEL_TYPE_ICBC,"工行支付");
		CHANNEL_TYPE_LABLE.put(CHANNEL_TYPE_UMS,"银联商务");
	}

	/**
	 * 交易状态：TRADE_WAIT ：等待支付
	 * PAYING:用户正在付款
	 * USER_SCANED:用户已扫码
	 * CREATE_FAIL:订单创建失败
	 * TRADE_CLOSED:已关闭
	 * TRADE_CANCEL:已撤销
	 * PAY_FAIL:支付失败
	 * PAY_SUCCESS:支付成功
	 */
	public final static String TRADE_STATUS_WAIT = "TRADE_WAIT";
	public final static String TRADE_STATUS_PAYING = "PAYING";
	public final static String TRADE_STATUS_SCANED = "USER_SCANED";
	public final static String TRADE_STATUS_CLOSED = "TRADE_CLOSED";
	public final static String TRADE_STATUS_CANCEL = "TRADE_CANCEL";
	public final static String TRADE_STATUS_PAID = "PAY_SUCCESS";
	public final static String TRADE_STATUS_FAIL = "PAY_FAIL";

	/**
	 * PARTIAL_REFUND:部分退款
	 * FULL_REFUND:全额退款
	 */
	public final static String PARTIAL_REFUND = "PARTIAL_REFUND";
	public final static String FULL_REFUND = "FULL_REFUND";

	/**
	 * 退款状体：REFUND_WAITING：正在提交退款，REFUND_SUCCESS:退款提交成功,REFUND_FAILED:退款失败，REFUND_FINISHED:退款成功，REFUND_CHANGE:退款无法到账，需要人工介入
	 */
	public static final String REFUND_WAITING = "REFUND_WAITING";
	public static final String REFUND_SUCCESS = "REFUND_SUCCESS";
	public static final String REFUND_FAILED = "REFUND_FAILED";
	public static final String REFUND_FINISHED = "REFUND_FINISHED";
	public static final String REFUND_CHANGE = "REFUND_CHANGE";


	/** 未核对*/
	public static final String CHECK_STATUS_UNCHECK = "UNCHECK";
	/** 已核对 */
	public static final String CHECK_STATUS_CHECK_SUCCESS = "CHECK_SUCCESS";
	/** 核对失败 */
	public static final String CHECK_STATUS_CHECK_FAIL = "CHECK_FAIL";

	public static final int MAX_CANCEL_RETRY = 5;
	public static final long CANCEL_DURATION_MS = 5*1000;

	public static final String PRE_PRODUCT_CODE = "PRODUCT_SIGN_";

	/** 撤销交易重试次数 **/
	public static final int CANCEL_ATTEMPT_NUM = 3;
	/** 撤销交易等待时间（分钟） **/
	public static final int CANCEL_WAIT_TIME = 5;

	public static class WxConstant {
		public final static String TRADE_TYPE_APP = "APP";									// APP支付
		public final static String TRADE_TYPE_JSPAI = "JSAPI";								// 公众号支付或小程序支付
		public final static String TRADE_TYPE_NATIVE = "NATIVE";							// 原生扫码支付
		public final static String TRADE_TYPE_MWEB = "MWEB";								// H5支付

		public static final String FAIL     = "FAIL";
		public static final String SUCCESS  = "SUCCESS";
		public static final String USERPAYING = "USERPAYING";
		public static final String CLOSED = "CLOSED";

		public static final String RETURN_CODE_SUCCESS = "SUCCESS";
		public static final String RETURN_CODE_FAIL = "FAIL";
		public static final String RESULT_CODE_SUCCESS = "SUCCESS";
		public static final String RESULT_CODE_FAIL = "FAIL";

		public static final String RETURNCODE = "return_code";
		public static final String RESULTCODE = "result_code";

		public final static String MCH_TYPE_SPECIAL = "SPECIAL";
		public final static String MCH_TYPE_NORMAL = "NORMAL";

		public static final String HMACSHA256 = "HMAC-SHA256";
		public static final String MD5 = "MD5";

		public static final String FIELD_SIGN = "sign";
	}

	public static class AliConstant {
		public final static String ENABLE_PAY_CHANNELS = "balance,moneyFund,bankPay,creditCard,pcredit,debitCardExpress,pcreditpayInstallment,credit_group";
		public final static String SUCCESS = "10000";
	}


	public static final String MSG_TYPE_GH = "0";
	public static final String MSG_TYPE_PAY = "1";
	public static final String MSG_TYPE_YYQHTX = "2";

	public static Map<String,String> TEMPLATEMESSAGEBYTYPE = new HashMap<>();
	static {
		TEMPLATEMESSAGEBYTYPE.put(MSG_TYPE_PAY,"-EeesEcJlpdHvTAz4jnOvfuPVzcPW2_RO5dLrrbQmNU");
		TEMPLATEMESSAGEBYTYPE.put(MSG_TYPE_GH,"XF_XJ9Y2sfSVP0vsx2Bqgd4NqZI13CSiUdGTOYuAHjk");
		TEMPLATEMESSAGEBYTYPE.put(MSG_TYPE_YYQHTX,"D-GVAj-L9kBtdRG12TkjJECA3FRMd48QsTXslSwzngM");
	}



	public static final String HAS_BIND = "HAS_BIND";
	public static final String NO_BIND = "NO_BIND";

	public static final String OSS_TYPE_IMG = "IMG";
	public static final String OSS_TYPE_CERT = "CERT";

	public static final String USER_ADMIN = "ADMIN";
	public static final String USER_NORMAL = "NORMAL";

	public static final String LOG_KEY = "LOG_KEY";
	public static final String LOG_REQUEST = "LOG_REQUEST";
	public static final String LOG_RESPONSE = "LOG_RESPONSE";

	public static class CcbConstant {
		/**
		 * 建行网银网关地址
		 */
		public final static String bankURL = "/CCBIS/ccbMain?CCB_IBSVersion=V6";

		public final static String ccbGateWayUrl = "/CCBIS/B2CMainPlat_00_ENPAY";

	}

	public static class TradeTraceOperate{
		/** 下单 */
		public final static String ORDER_PAY = "orderPay";
		/** 同步查询 */
		public final static String ORDER_SYN_QUERY = "orderSynQuery";
		/** 退款 */
		public final static String ORDER_REFUND = "orderRefund";
		/** 撤销 */
		public final static String ORDER_CANCEL = "orderCancel";
		/** 转账 */
		public final static String ORDER_TRANSFER = "orderTransfer";

	}

	//配置验证相关数据
	public static final String VALI_CONFIG_MCHNO = "0000";
	public static final String VALI_CONFIG_APPID = "APP00000000000000000000";

	public static final String APP_TYPE_PAY = "olp";
	public static final String APP_TYPE_RECONCILIATION = "reconciliation";
	public static final String APP_TYPE_OLP = "olp";

	//tradeBean version key
	public static final String TRADE_BEAN_VERSION_KEY = "trade_bean_version_";

	public static final String SIGN_ENABLE = "enable";
	public static final String SIGN_DISABLE = "disable";

	public static final String PLAT_WXCONFIG_PMCHNO = "1465687102";
	public static final String PLAT_WXCONFIG_SIGNTYPE = "MD5";
	public static final String PLAT_WXCONFIG_APIKEY = "1234ABcd1234ABcd1234ABcd1234ABcd";
	public static final String PLAT_WXCONFIG_APPSECRET = "6e4aeb26bc02097d7fca3789deabde44";
	public static final String PLAT_WXCONFIG_APPID = "wx8e5cb58e11befa99";
	public static final String PLAT_WXCONFIG_CERTPATH  = "aliyunoss:trade-cert/wxpay_common.p12";


	public static final String PLAT_PSERVER_NAME = "p0000";

	public static final String PAY_PARAM_APPKEY = "appKey";
	public static final String PAY_PARAM_MCHNO = "mchNo";
	public static final String PAY_PARAM_TIMESTAMP = "timestamp";
	public static final String PAY_PARAM_PRODUCTCODE = "productCode";
	public static final String PAY_PARAM_SCENEID = "sceneId";
	public static final String PAY_PARAM_SUBSCENEID = "subSceneId";
	public static final String PAY_PARAM_SUBMCHNO = "subMchNo";
	public static final String PAY_PARAM_TRADENO = "tradeNo";
	public static final String PAY_PARAM_CODEURL = "codeUrl";
	public static final String PAY_PARAM_BILLNO = "billNo";
	public static final String PAY_PARAM_ACCOUNTID = "accountId";
	public static final String PAY_PARAM_TRADEDATE = "tradeDate";
	public static final String PAY_PARAM_CHANNELTRADENO = "channelTradeNo";
	public static final String PAY_PARAM_TRADESTATE = "tradeState";
	public static final String PAY_PARAM_CHANNELTYPE = "channelType";
	public static final String PAY_PARAM_TOTALAMOUNT = "totalAmount";
	public static final String PAY_PARAM_SUBJECT = "subject";
	public static final String PAY_PARAM_BODY = "body";
	public static final String PAY_PARAM_CREATEDATETIME = "createDateTime";
	public static final String PAY_PARAM_QRURL = "codeUrl";
	public static final String PAY_PARAM_AUTHCODE = "authCode";
	public static final String PAY_PARAM_DEVICEINFO = "deviceInfo";
	public static final String PAY_PARAM_PAIDTIME = "paidTime";
	public static final String PAY_PARAM_REFUNDNO  = "refundNo";
	public static final String PAY_PARAM_CHANNELREFUNDNO  = "channelRefundNo";
	public static final String PAY_PARAM_REFUNDAMOUNT  = "refundAmount";
	public static final String PAY_PARAM_REFUNDREASON  = "refundReason";
	public static final String PAY_PARAM_REFUNDTIME  = "refundTime";
	public static final String PAY_PARAM_OPENID = "openId";
	public static final String PAY_PARAM_REFUNDSTATUS = "refundStatus";
	public static final String PAY_PARAM_NEEDQUERY = "needQuery";
	public static final String PAY_PARAM_BANKTYPE = "bankType";
	public static final String PAY_PARAM_NOTIFYURL = "notifyUrl";
	public static final String PAY_PARAM_RETURNURL = "returnUrl";
	public static final String PAY_PARAM_SIGN = "sign";
	public static final String PAY_PARAM_ISEXIST = "isExist";
	public static final String PAY_PARAM_DATE = "billDate";
	public static final String PAY_ZIMID = "zimid";
	public static final String PAY_ZIMINITCLIENTDATA = "zimInitClientData";
	public static final String PAY_PARAM_CLIENTIP = "clientIp";
	public static final String PAY_PARAM_METAININFO = "metainInfo";
	public static final String PAY_PARAM_FACEPAYMETHOD = "facePayMethod";

	public static final String PAY_PARAM_EXPIRETIMEMINUTES = "expireTimeMinutes";

	public static final String PAY_PARAM_PAYWAY = "payWay";

	public static final String PAY_PARAM_PAYUSERINFO = "payUserInfo";
	public static final String PAY_PARAM_BATCHNO  = "batchNo";
	public static final String PAY_PARAM_TRACESEQ  = "traceSeq";
	public static final String PAY_PARAM_DEVICENO  = "deviceNo";
	public static final String PAY_PARAM_CARDNO  = "cardNo";
	public static final String PAY_PARAM_TRADETYPE = "tradeType";
	public static final String PAY_PARAM_SYSNO = "sysNo";
	public static final String PAY_PARAM_DESC = "desc";

	public static final String PRODUCT_PREFIX_UE = "UE";

	public static final String PRODUCT_PREFIX_ABC_UE = "ABC_UE";

	public static class ORDER_MONITOR{
		/** 订单创建 */
		public final static String ORDER_CREATE = "CREATE";
		/** 超时关闭 */
		public final static String ORDER_TIMEOUTTOCLOSE = "TIMEOUTTOCLOSE";
		/** 超时撤销 */
		public final static String ORDER_TIMEOUTTOCANCEL = "TIMEOUTTOCANCEL";
		/** 用户扫码 */
		public final static String ORDER_USERSCANED = "USERSCANED";
		/** 订单查询 */
		public final static String ORDER_TRADEQUERY = "TRADEQUERY";
		/** 订单收到通知 */
		public final static String ORDER_TRADENOTIFY = "TRADENOTIFY";
		/** 订单支付失败 */
		public final static String ORDER_PAYFAIL = "PAYFAIL";
		/** 订单支付成功 */
		public final static String ORDER_PAYSUCCESS = "PAYSUCCESS";
		/** 订单支付位置 */
		public final static String ORDER_TRADEWAIT = "TRADEWAIT";
		/** 退款申请 */
		public final static String ORDER_APPLYREFUND = "APPLYREFUND";
		/** 退款成功 */
		public final static String ORDER_REFUNDSUCCESS = "REFUNDSUCCESS";
		/** 退款失败 */
		public final static String ORDER_REFUNDFAIL = "REFUNDFAIL";
		/** 发送通知 */
		public final static String ORDER_SENDNOTIFY = "SENDNOTIFY";
		/** 通知成功 */
		public final static String ORDER_NOTIFYSUCCESS = "NOTIFYSUCCESS";
		/** 通知失败 */
		public final static String ORDER_NOTIFYFAIL = "NOTIFYFAIL";
	}

	public static final int NOTIFY_MAX_TIME = 9;
	public static final String NOTIFY_SUCCESS = "success";
	public static Map<Integer,Integer> orderNotifyInterval = new HashMap<>();
	static {
		orderNotifyInterval.put(1,15);
		orderNotifyInterval.put(2,15);
		orderNotifyInterval.put(3,30);
		orderNotifyInterval.put(4,180);
		orderNotifyInterval.put(5,1800);
		orderNotifyInterval.put(6,1800);
		orderNotifyInterval.put(7,1800);
		orderNotifyInterval.put(8,1800);
		orderNotifyInterval.put(9,3600);
	}

	public final static String MESSAGE_TYPE_SYNC = "SYNC";
	public final static String MESSAGE_TYPE_ASYN = "ASYN";


	/** 交易类型-交易 */
	public static final String DZ_TRADETYPE_PAY = "PAY";
	/** 交易类型-退款 */
	public static final String DZ_TRADETYPE_REFUND = "REFUND";

}
